﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace WebAppTemplate.CSR.Repository.Entities
{
    public class Demo
    {
        public long Id { get; set; }
        public string? Value { get; set; }
        public DemoOneWithOne? OneWithOne { get; set; }
        public List<DemoOneWithMore>? OneWithMore { get; set; }
        public List<DemoMoreWithMore>? MoreWithMore { get; set; } 
    }

    public class DemoConfig : IEntityTypeConfiguration<Demo>
    {
        public void Configure(EntityTypeBuilder<Demo> builder)
        {
            builder.HasKey(it => it.Id);
            builder.Property(it => it.Id).ValueGeneratedNever();

            builder.HasOne(it => it.OneWithOne).WithOne(it => it.Demo);
            builder.HasMany(it => it.OneWithMore).WithOne(it => it.Demo);
            builder.HasMany(it => it.MoreWithMore).WithMany(it => it.Demo);
        }
    }
}
